package com.ssy.lingxi.transaction.controller.applet;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.transaction.api.dto.request.*;
import com.ssy.lingxi.transaction.api.dto.response.*;
import com.ssy.lingxi.transaction.service.IQuoteService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @Author xiaomai
 * @Description 小程序业务员报价单
 * @Date 2022/3/23 18:22
 * @menu 小程序业务员报价单
 **/
@RestController
@RequestMapping("/transaction/applet")
public class AppletQuoteController extends BaseController {

    @Resource
    private IQuoteService quoteService;

    /**
     * 询价报价-历史报价单列表查询
     *
     * @param commoditySkuId 商品skuId
     */
    @GetMapping("/product/quotation/history/list")
    public Wrapper<PageData<HistoryQuoteListResponse>> getHistoryQuoteList(HttpServletRequest httpServletRequest, PageVO pageVO, @RequestParam("commoditySkuId") Long commoditySkuId) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.getHistoryQuoteList(commoditySkuId, pageVO, sysUser);
    }

    /**
     * 询价报价-新增询价报价单
     */
    @PostMapping("/product/quotation/add")
    public Wrapper productQuotationAdd(@Valid @RequestBody ProductQuotationAddRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.productQuotationAdd(request, sysUser);
    }

    /**
     * 询价报价-报价单详情
     */
    @GetMapping("/product/quotation/details")
    public Wrapper<ProductQuotationDetailsResponse> productQuotationDetails(ProductQuotationDetailsRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.productQuotationDetails(request, sysUser);
    }

    /**
     * 查询各个状态报价单的数量
     *
     * @return
     */
    @GetMapping("/product/quotation/sum")
    public Wrapper<AppletProductQuotationSumResponse> quotationSum() {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return quoteService.quotationSum(sysUser);
    }

    /**
     * 询价报价-报价单审核列表（全部、待提交审核、待审核一级、待审核二级、待提交）
     */
    @GetMapping("/product/quotation/audit/list")
    public Wrapper<PageData<AppletProductQuotationListResponse>> quotationAuditList(@Valid AppletProductQuotationListRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.quotationAuditList(request, sysUser);
    }

    /**
     * 询价报价-提交审核
     */
    @PostMapping("/product/quotationt/submit")
    public Wrapper productQuotationSubmit(@Valid @RequestBody ProductQuotationSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.productQuotationSubmit(request, sysUser);
    }

    /**
     * 询价报价-审核报价单（一级）
     */
    @PostMapping("/product/quotationt/audit/submit/one")
    public Wrapper productQuotationAuditSubmit(@Valid @RequestBody ProductQuotationSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.productQuotationAuditSubmit(request, sysUser);
    }

    /**
     * 询价报价-审核报价单（二级）
     */
    @PostMapping("/product/quotationt/audit/submit/two")
    public Wrapper productQuotationAuditSubmitTwo(@Valid @RequestBody ProductQuotationSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.productQuotationAuditSubmitTwo(request, sysUser);
    }

    /**
     * 询价报价-提交报价单
     */
    @PostMapping("/product/quotationt/to/submit")
    public Wrapper productQuotationToSubmit(@Valid @RequestBody ProductQuotationSubmitRequest request, HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return quoteService.productQuotationToSubmit(request, sysUser);
    }


}
